package com.weilele.mvvmlib.sample

import android.os.Bundle
import com.google.android.material.slider.LabelFormatter
import com.google.android.material.slider.Slider
import com.weilele.base.library.BaseActivity
import com.weilele.mvvmlib.databinding.ActivitySlideBarBinding

class SlideBarActivity : BaseActivity<ActivitySlideBarBinding>() {
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        testSlideBar()
        testRangSlideBar()
    }


    private fun testSlideBar() {
        mBinding.slideBar.let { it ->
            it.valueTo = 100f
            it.valueFrom = 10f
            it.value = 80f
            it.isTickVisible = true
            it.setLabelFormatter { v ->
                "$v%"
            }
            it.labelBehavior = LabelFormatter.LABEL_WITHIN_BOUNDS
            it.addOnChangeListener { slider, value, fromUser ->

            }
            it.addOnSliderTouchListener(object : Slider.OnSliderTouchListener {
                override fun onStartTrackingTouch(slider: Slider) {

                }

                override fun onStopTrackingTouch(slider: Slider) {
                }
            })
        }
    }

    private fun testRangSlideBar() {
        mBinding.rangSlideBar.let {
            it.valueTo = 100f
            it.valueFrom = 10f
            it.values = listOf(10f, 50f, 80f)
//            it.isTickVisible=false
            it.minSeparation = 20f
            it.labelBehavior = LabelFormatter.LABEL_FLOATING
        }
    }
}